<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<table border="1">
    <tr>
        <th>名称</th>
        <th>库存</th>
        <th>价格</th>
    </tr>
</table>
    <script>
        let arr=[
            {name:'手机',num:10,price:5000},
            {name:'电脑',num:20,price:10000},
            {name:'鼠标',num:30,price:100},
            {name:'键盘',num:40,price:200}
        ]
        let table=document.querySelector('table');
        for(var i=0;i<arr.length;i++)
        {
            let tr=document.createElement('tr');
            let td1=document.createElement('td');
            let td2=document.createElement('td');
            let td3=document.createElement('td');
            td1.innerHTML=arr[i].name;
            td2.innerHTML=arr[i].num;
            td3.innerHTML=arr[i].price;
            tr.append(td1,td2,td3);
            table.append(tr);
        }
    </script>



</body>
</html>